package cn.zhaosunny.soap

import cn.zhaosunny.soap.annonations.WebParam
import cn.zhaosunny.soap.annonations.WebService
import java.lang.reflect.Method
import java.lang.reflect.Type

/**
 *
 * @author zhaoyang 2021/11/30
 */

class SoapRequest(service: Class<*>, method: Method, args: Array<Any>) {

    var nameSpace: String? = ""
    var endPoint: String? = ""
    var methodName: String? = ""
    var params: LinkedHashMap<String, Any> = LinkedHashMap()
    var returnType: Type? = null
    var genericReturnType: Type? = null

    init {
        this.methodName = method.name
        this.returnType = method.returnType
        this.genericReturnType = method.genericReturnType
        service.annotations.forEach {
            if (it is WebService) {
                this.nameSpace = it.targetNamespace
                this.endPoint = it.targetEndPoint
            }
        }
        params.clear()
        method.parameterAnnotations.forEachIndexed { index, annotations ->
            annotations.forEach { annotation ->
                if (annotation is WebParam) {
                    params[annotation.name] = args[index]
                }
            }

        }
    }
}